import Vue from 'vue'
import VueRouter from 'vue-router'
import layout from '../views/layout'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'layout',
    component: layout,
    children: [
      {
        path: '/',
        redirect: "/home"
      },
      {
        path: 'home',
        name: 'home',
        component: () => import('../views/home'),
      },
      {
        path: 'list',
        name: 'list',
        component: () => import('../views/list'),
      },
      {
        path: 'cart',
        name: 'cart',
        component: () => import('../views/cart'),
      },
      {
        path: 'my',
        name: 'my',
        component: () => import('../views/my'),
      }
    ]
  },
  {
    path: '/detail/:id',
    name: 'detail',
    component: () => import('../views/detail'),
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/login'),
  }

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
